package com.zzyl.common.core.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Setter;

/**
 * Entity基类
 */
@Data
@ApiModel("Entity基类")
public class BaseEntity implements Serializable {
    //序列化版本ID
    private static final long serialVersionUID = 1L;

    //搜索值
    @JsonIgnore //序列化和反序列化过程中忽略该字段
    @TableField(exist = false) //该字段不存在于数据库表中
    private String searchValue;

    @ApiModelProperty(value = "创建者")
    @TableField(fill = FieldFill.INSERT) //自动填充，指定填充策略
    private String createBy;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT) //自动填充，指定填充策略
    private Date createTime;

    @ApiModelProperty(value = "更新者")
    @TableField(fill = FieldFill.INSERT) //自动填充，指定填充策略
    private String updateBy;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.UPDATE) //自动填充，指定填充策略
    private Date updateTime;

    @ApiModelProperty(value = "备注")
    @TableField(fill = FieldFill.UPDATE) //自动填充，指定填充策略
    private String remark;

    @Setter
    @ApiModelProperty(value = "请求参数")
    @TableField(exist = false) //该字段不存在于数据库表中
    private Map<String, Object> params;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }
}